package com.vietsanto.common.controller;

import com.vietsanto.common.model.KidsModel;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by VIET on 12/11/2014.
 */

@Controller
@RequestMapping("/kids")
public class KidsController{

    @RequestMapping(value = "/{name}", method = RequestMethod.GET)
    public String getMovie(@PathVariable String name, ModelMap model) {
        model.addAttribute("msg", name);
        return "list";
    }

    @RequestMapping(method = RequestMethod.GET)
    public String getDefaultMovie(ModelMap model) {
        model.addAttribute("msg", "this is kids page");
        return "list";
    }

    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public @ResponseBody KidsModel getKids(@RequestParam(value = "name", required = true) String name,
                                           @RequestParam(value = "age", required = false) int age){
        return new KidsModel(name, age);
    }
}
